package com.wsk.time;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class CurrentTime {
	//获取详细时间 String
	public static String getCurrentTime(){
		Date time=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String currentTime=sdf.format(time);
		return currentTime;
	}
	//获取年月日 String
	public static String getCurrentDate(){
		Date time=new Date();
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		String currentDate=sdf.format(time);
		return currentDate;
	}
	//将String转化为Date
	public static Date getDate(String time) throws ParseException {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		Date date = sdf.parse(time);
        System.out.println(date);
		return date;
	}
    public static void main(String[] args) throws ParseException {
        System.out.println(getDate(getCurrentDate()));
    }
}
